package xio.ccf_201512;

import java.util.Scanner;

/**
 * 201512-3 画图
 * Created by ywb47 on 2017/10/5.
 */
public class Paint {
    private static char[][] src; //画布
    private static int xCount;
    private static int yCount;
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
         xCount = sc.nextInt();
         yCount = sc.nextInt();

         //初始化画布
         src = new char[xCount][yCount];
        for (int i = 0; i < xCount; i++) {
            for (int j = 0; j < yCount; j++) {
                src[i][j] = '.';
            }
        }

        //顺序执行操作
        int OpCount = sc.nextInt();
        for (int i = 0; i < OpCount; i++) {
            int type = sc.nextInt();
            if (type == 0){ //连线
                int x1 = sc.nextInt();
                int y1 = sc.nextInt();
                int x2 = sc.nextInt();
                int y2 = sc.nextInt();
                line(x1,y1,x2,y2);
            }else {        //填充字符
                int x1 = sc.nextInt();
                int y1 = sc.nextInt();
                char c = sc.next().charAt(0);
                draw(x1,y1,c);
            }
        }

        //输出
        for (int j = yCount-1; j >= 0; j--) {
            for (int i = 0; i < xCount; i++) {
                System.out.print(src[i][j]);
            }
            System.out.print("\n");
        }

    }

    private static void line(int x1, int y1, int x2, int y2){
        if (x1 == x2) {
            int minY = Math.min(y1,y2);
            int maxY = Math.max(y1,y2);
            for (int i=minY;i<=maxY;i++){
                if (src[x1][i] == '-' || src[x1][i] == '+'){
                    src[x1][i] = '+';
                }else {
                    src[x1][i] = '|';
                }
            }
        }else {
            int minX = Math.min(x1,x2);
            int maxX = Math.max(x1,x2);
            for (int i=minX;i<=maxX;i++){
                if (src[i][y1] == '|' || src[i][y1] == '+'){
                    src[i][y1] = '+';
                }else {
                    src[i][y1] = '-';
                }
            }
        }
    }

    private static void draw(int x, int y, char c){
        if (x>=0 && y>=0 && x<xCount && y<yCount   //画布范围内
                && src[x][y] != '-' && src[x][y] != '+' && src[x][y] != '|' //不在线段上
                && src[x][y] != c){
            src[x][y] = c;
            draw(x-1,y,c);
            draw(x+1,y,c);
            draw(x,y-1,c);
            draw(x,y+1,c);
        }
    }


}
